﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint.Schema;
using Team2010.IO.Definitions;
using System.IO;

namespace Team2010.TestApp
{
    class Program
    {
        static void Main(string[] args)
        {
            WebTemplates temps = new WebTemplates();
            Template t = new Template();
            t.ID = 1001;
            t.Name = "GeneratedTemplate";
            t.Configuration.Description = "Creates a site from a generated Site Definition";
            t.Configuration.Title = "Site from Generated Site Definition";
            t.Configuration.DisplayCategory = "Team2010";
            
            Template[] Temps = {t};
            temps.templates = Temps;

            using (TextWriter tw = new StreamWriter(@"c:\temp\webtemp" + t.Name.Trim() + ".xml"))
            {
                Team2010.IO.Strings strings = new Team2010.IO.Strings();
                string s = strings.SerializeToXmlString(temps);
                s = s.Replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>", 
                    "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "\r\n"
                    +"<!-- _lcid=\"1033\" _version=\"14.0.4536\" _dal=\"1\" -->" + "\r\n"
                    + "<!-- _LocalBinding -->");
                s = s.Replace("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"", "xmlns:ows=\"Microsoft SharePoint\"");
                s = s.Replace(" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"", "");
                tw.Write(s);
            }
        }
    }
}
